home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
edit
/
me_cd25.zip
/
MC2MUTT.ZIP
/
TOBASE.MUT
< prev
Wrap
Text File
|
1992-11-09
|
563b
|
25 lines
; tobase(n,base): convert n (base 10) to base. eg (tobase 10 16) => "A"
; C Durland
(defun
mod (int n base) ; n mod base = n - (n/base)*base
{ (- n (* (/ n base) base)) }
tobase (int n base)
{
(if (< n base) (extract-elements "0123456789ABCDEF" n 1)
(concat
(tobase (/ n base) base) ; tobase n/base base
(tobase (mod n base) base) ; tobase (n mod base) base
)
)
}
)
(const NUMBER 0x03)
(defun
MAIN
{
(msg (tobase
(convert-to NUMBER (ask "n = "))
(convert-to NUMBER (ask "base = "))))
})